import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AdmBookReturnVO, AdmBookReturnForm, AdmBookReturnQuery } from '@/api/general/administration/book/return/types';

/**
 * 查询图书归还列表
 * @param query
 * @returns {*}
 */

export const listAdmBookReturn = (query?: AdmBookReturnQuery): AxiosPromise<AdmBookReturnVO[]> => {
  return request({
    url: '/administration/admBookReturn/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询图书归还详细
 * @param id
 */
export const getAdmBookReturn = (id: string | number): AxiosPromise<AdmBookReturnVO> => {
  return request({
    url: '/administration/admBookReturn/' + id,
    method: 'get'
  });
};

/**
 * 新增图书归还
 * @param data
 */
export const addAdmBookReturn = (data: AdmBookReturnForm) => {
  return request({
    url: '/administration/admBookReturn',
    method: 'post',
    data: data
  });
};

/**
 * 修改图书归还
 * @param data
 */
export const updateAdmBookReturn = (data: AdmBookReturnForm) => {
  return request({
    url: '/administration/admBookReturn',
    method: 'put',
    data: data
  });
};

/**
 * 删除图书归还
 * @param id
 */
export const delAdmBookReturn = (id: string | number | Array<string | number>) => {
  return request({
    url: '/administration/admBookReturn/' + id,
    method: 'delete'
  });
};

/**
 * 获取当前用户未归还书籍
 */
export const getUserUnreturnedBooks = (data: AdmBookReturnForm): AxiosPromise<AdmBookReturnVO[]> => {
  // 假设用户 ID 从登录状态获取
  return request({
    url: '/administration/admBookReturn/getUserUnreturnedBooks',
    method: 'post',
    data: data
  });
}

/**
 * 批量添加图书
 * @param data 批量添加图书的请求参数
 * @returns
 */
export function batchAddBooks(data: any) {
  return request({
    url: '/administration/admBookReturn/batchAdd',
    method: 'post',
    data
  })
}
